/**
 * Created by CK on 2016/10/9.
 */
$(document).ready(function(){
    var teacherId = xhTool.getQuery('iTeacherId');
    var schoolId  = xhTool.getQuery('iSchoolId');
    var appCodeDom = $('#sl_AppCode');
    var appCode;
    var tab = $('#tab_Class');
    appCodeDom.select2();
    $('#bt_ViewClass').click(function(){
        tab.closeAllTab();
        appCode = appCodeDom.val();
        if(!appCode) return false;
        $.post(baseUrl + 'Class/getClassInfoByTeacher', {iTeacherId: teacherId, iSchoolId: schoolId, iAppCode: appCode}, function(classInfo){
            if(classInfo.R != 200) {
                window.top.xhTop.showMessage({title: classInfo.I, type: 'error'});
                return false;
            }
            if(classInfo.D.length == 0){
                alert('无开班信息');
                return false;
            }
            $.each(classInfo.D, function(key, classOne){
                tab.tabs('add', {
                    title:      classOne.title,
                    content:    '<iframe frameborder="0" style="width:100%;" src="' + classOne.src + '"></iframe>',
                    closable:   false,
                    border:     false
                });
            });
        }, 'json');
    });
});